package com.zx.controller;

import com.zx.entity.User;
import com.zx.service.UserServiceImpl;
import com.zx.util.SqlSessionFactoryUtil;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @RequestMapping("/login")
    public String login(String name, String password){
        User user=new User(name,password);
        ApplicationContext ac=SqlSessionFactoryUtil.getAc();
        UserServiceImpl us=ac.getBean("userServiceImpl",UserServiceImpl.class);
        User u=us.userLogin(user);
        if (u!=null){
            return "redirect:/page/list.html";
        }else {
            return "redirect:/page/login.html";
        }
    }
}
